Skip to content

Commit

Permalink
failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
romainmenke committed Dec 29, 2023
1 parent a0d9f10 commit a4626e9
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions test/no-work-result.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import postcss = require('../lib/postcss.js')
import stringify = require('../lib/stringify.js')
import { spy } from 'nanospy'
import { SourceMapGenerator } from 'source-map-js'
import { test } from 'uvu'
import { equal, instance, is, not, throws, type } from 'uvu/assert'

import NoWorkResult from '../lib/no-work-result.js'
import parse from '../lib/parse.js'
import Processor from '../lib/processor.js'

let processor = new Processor()
Expand Down Expand Up @@ -98,4 +101,72 @@ test('prints its object type', () => {
is(Object.prototype.toString.call(result), '[object NoWorkResult]')
})

test('no work result matches lazy result', async () => {
let source = '.foo { color: red }\n';

let lazyResult = await postcss([]).process(source, {
from: 'foo.css',
map: false,
syntax: { parse, stringify }
});

let noWorkResult = await postcss([]).process(source, {
from: 'foo.css',
map: false
});

equal(lazyResult.css, noWorkResult.css);
})

test('no work result matches lazy result when map is true', async () => {
let source = '.foo { color: red }\n';

let lazyResult = await postcss([]).process(source, {
from: 'foo.css',
map: true,
syntax: { parse, stringify }
});

let noWorkResult = await postcss([]).process(source, {
from: 'foo.css',
map: true
});

equal(lazyResult.css, noWorkResult.css);
})

test('no work result matches lazy result when the source contains an inline source map', async () => {
let source = '.foo { color: red }\n\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZvby5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEiLCJmaWxlIjoiZm9vLmNzcyIsInNvdXJjZXNDb250ZW50IjpbIi5mb28geyBjb2xvcjogcmVkIH1cbiJdfQ== */\n';

let lazyResult = await postcss([]).process(source, {
from: 'foo.css',
map: false,
syntax: { parse, stringify }
});

let noWorkResult = await postcss([]).process(source, {
from: 'foo.css',
map: false
});

equal(lazyResult.css, noWorkResult.css);
})

test('no work result matches lazy result when map is true and the source contains an inline source map', async () => {
let source = '.foo { color: red }\n\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZvby5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEiLCJmaWxlIjoiZm9vLmNzcyIsInNvdXJjZXNDb250ZW50IjpbIi5mb28geyBjb2xvcjogcmVkIH1cbiJdfQ== */\n';

let lazyResult = await postcss([]).process(source, {
from: 'foo.css',
map: true,
syntax: { parse, stringify }
});

let noWorkResult = await postcss([]).process(source, {
from: 'foo.css',
map: true
});

equal(lazyResult.css, noWorkResult.css);
})

test.run()

0 comments on commit a4626e9

Please sign in to comment.