You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
668 B
JavaScript
29 lines
668 B
JavaScript
import assert from 'assert'
|
|
import cheerio from 'cheerio'
|
|
|
|
import {
|
|
addScore,
|
|
getScore,
|
|
} from './index'
|
|
|
|
describe('Scoring utils', () => {
|
|
describe('addScore(node, $, amount)', () => {
|
|
it(`adds the specified amount to a node's score`, () => {
|
|
const $ = cheerio.load('<p score="25">Foo</p>')
|
|
let $node = $('p').first()
|
|
|
|
$node = addScore($node, $, 25)
|
|
assert.equal(getScore($node), 50)
|
|
})
|
|
|
|
it(`adds score if score not yet set (assumes score is 0)`, () => {
|
|
const $ = cheerio.load('<p>Foo</p>')
|
|
let $node = $('p').first()
|
|
|
|
$node = addScore($node, $, 25)
|
|
assert.equal(getScore($node), 25)
|
|
})
|
|
|
|
})
|
|
})
|