File indexing completed on 2024-11-17 04:55:14

0001 /* This Source Code Form is subject to the terms of the Mozilla Public
0002  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
0003  * You can obtain one at http://mozilla.org/MPL/2.0/. */
0004 /* global describe, it, before */
0005 
0006 const assert = require('assert')
0007 const { AdBlockClient } = require('../..')
0008 
0009 describe('getFingerprint', function () {
0010   before(function () {
0011     this.adBlockClient = new AdBlockClient()
0012   })
0013   it('Extracts simple fingerprint', function () {
0014     assert.strictEqual(this.adBlockClient.getFingerprint('fdasfdsafdas'), 'fdasfd')
0015   })
0016   it('Does not use special characters for fingerprints', function () {
0017     assert.strictEqual(this.adBlockClient.getFingerprint('*fdasfdsafdas'), 'fdasfd')
0018   })
0019   it('Extracts host anchored filter fingerprint', function () {
0020     assert.strictEqual(this.adBlockClient.getFingerprint('||brave.com'), 'brave.')
0021   })
0022   it('Does not extract a fingerprint for strings that are too short', function () {
0023     assert.strictEqual(this.adBlockClient.getFingerprint('prime'), undefined)
0024   })
0025   it('Does not extract a fingerprint for blacklisted strings', function () {
0026     assert.strictEqual(this.adBlockClient.getFingerprint('https://'), undefined)
0027   })
0028   it('Extract a fingerprint for short host anchored filters', function () {
0029     assert.strictEqual(this.adBlockClient.getFingerprint('||a.ca/brianbondy'), 'a.ca/b')
0030   })
0031 })