diff --git a/test/fixtures/input b/test/fixtures/input index e69de29..214ff89 100644 --- a/test/fixtures/input +++ b/test/fixtures/input @@ -0,0 +1,13 @@ +# Frontend Redirects + +Redirect 301 /deleted-page/ https://website.com/new-page/ +Redirect 302 /new-feature/ https://website.com/coming-soon/ + +# Admin Redirects + +Redirect 301 /admin/ https://website.com/?login=true + +# Test alignment + +Redirect 301 /old-short-url/ https://website.com/new-short-url/ +Redirect 301 /old-loooooooooong-url/ https://website.com/new-long-url/ diff --git a/test/fixtures/output b/test/fixtures/output new file mode 100644 index 0000000..6f5b37d --- /dev/null +++ b/test/fixtures/output @@ -0,0 +1,23 @@ +# Frontend Redirects + +location /deleted-page/ { + return 301 https://website.com/new-page/; +} +location /new-feature/ { + return 302 https://website.com/coming-soon/; +} + +# Admin Redirects + +location /admin/ { + return 301 https://website.com/?login=true; +} + +# Test alignment + +location /old-short-url/ { + return 301 https://website.com/new-short-url/; +} +location /old-loooooooooong-url/ { + return 301 https://website.com/new-long-url/; +} diff --git a/test/unit.js b/test/unit.js index 286ba7d..fb5b9ac 100644 --- a/test/unit.js +++ b/test/unit.js @@ -1,7 +1,15 @@ import test from 'ava'; +import { readFileSync } from 'fs'; import htconvert from '../dist/htconvert'; +const input = readFileSync('./fixtures/input', 'utf-8'); +const output = readFileSync('./fixtures/output', 'utf-8'); + test('htconvert should export a function', t => { t.is(typeof htconvert, 'function'); }); + +test('htconvert should match input with output', t => { + t.is(htconvert(input), output); +});