test(utils): make tests for relativeTo platform agnostic

This commit is contained in:
Hannes Diercks 2018-05-11 21:25:34 +02:00
parent c017da10f6
commit 919b5395af
No known key found for this signature in database
GPG Key ID: 5EE4BD6DCE65A843

View File

@ -1,3 +1,4 @@
import path from 'path'
import { Utils } from '../utils' import { Utils } from '../utils'
describe('utils', () => { describe('utils', () => {
@ -218,13 +219,16 @@ describe('utils', () => {
}) })
describe('relativeTo', () => { describe('relativeTo', () => {
const path1 = path.join(path.sep, 'foo', 'bar')
const path2 = path.join(path.sep, 'foo', 'baz')
test('makes path relative to dir', () => { test('makes path relative to dir', () => {
expect(Utils.relativeTo('/foo/bar', '/foo/baz')).toBe('../baz') expect(Utils.relativeTo(path1, path2)).toBe(Utils.wp(`..${path.sep}baz`))
}) })
test('keeps webpack inline loaders prepended', () => { test('keeps webpack inline loaders prepended', () => {
expect(Utils.relativeTo('/foo/bar', 'loader1!loader2!/foo/baz')) expect(Utils.relativeTo(path1, `loader1!loader2!${path2}`))
.toBe('loader1!loader2!../baz') .toBe(Utils.wp(`loader1!loader2!..${path.sep}baz`))
}) })
}) })
}) })