Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
herber committed Oct 1, 2018
1 parent 5546672 commit 9848295
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const avatar = require('../index');

test('generates avatar', () => {
const a = avatar('hello world');

expect(a).toEqual(`<?xml version="1.0" encoding="UTF-8"?>
<svg viewBox="0 0 80 80" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<linearGradient x1="0%" y1="0%" x2="100%" y2="100%" id="g">
<stop stop-color="rgb(255, 123, 0)" offset="0%"></stop>
<stop stop-color="rgb(0, 255, 123)" offset="100%"></stop>
</linearGradient>
</defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<rect id="Rectangle" fill="url(#g)" x="0" y="0" width="80" height="80"></rect>
</g>
</svg>`);
});

test('generates avatar with size', () => {
const a = avatar('hello world', 300);

expect(a.includes('width="300px"')).toBeTruthy();
expect(a.includes('height="300px"')).toBeTruthy();
});

0 comments on commit 9848295

Please sign in to comment.