| 1 | let { parse } = require('postcss') |
| 2 | let { test } = require('uvu') |
| 3 | let { is } = require('uvu/assert') |
| 4 | |
| 5 | let Selector = require('../lib/selector') |
| 6 | |
| 7 | let selector = new Selector('::selection', ['-moz-', '-ms-']) |
| 8 | let old = selector.old('-moz-') |
| 9 | |
| 10 | test('returns true on last rule', () => { |
| 11 | let css = parse('::selection {} ::-moz-selection {}') |
| 12 | is(old.isHack(css.last), true) |
| 13 | }) |
| 14 | |
| 15 | test('stops on another type', () => { |
| 16 | let css = parse('::-moz-selection {} ' + '@keyframes anim {} ::selection {}') |
| 17 | is(old.isHack(css.first), true) |
| 18 | }) |
| 19 | |
| 20 | test('stops on another selector', () => { |
| 21 | let css = parse('::-moz-selection {} a {} ::selection {}') |
| 22 | is(old.isHack(css.first), true) |
| 23 | }) |
| 24 | |
| 25 | test('finds unprefixed selector', () => { |
| 26 | let css = parse('::-moz-selection {} ' + '::-o-selection {} ::selection {}') |
| 27 | is(old.isHack(css.first), false) |
| 28 | }) |
| 29 | |
| 30 | test('finds old selector', () => { |
| 31 | let css = parse('body::-moz-selection {} body::selection {}') |
| 32 | is(old.check(css.first), true) |
| 33 | }) |
| 34 | |
| 35 | test('finds right', () => { |
| 36 | let css = parse('body:::-moz-selection {}') |
| 37 | is(old.check(css.first), false) |
| 38 | }) |
| 39 | |
| 40 | test.run() |