|
| 1 | +import { strictEqual } from 'assert' |
| 2 | +import rdf from '@rdfjs/data-model' |
| 3 | +import { describe, it } from 'mocha' |
| 4 | +import { isBoolean, isDecimal, isDouble, isLangString, isInteger, isString } from '../lib/utils.js' |
| 5 | +import * as ns from './support/namespaces.js' |
| 6 | + |
| 7 | +describe('utils', () => { |
| 8 | + describe('isBoolean', () => { |
| 9 | + it('should be a function', () => { |
| 10 | + strictEqual(typeof isBoolean, 'function') |
| 11 | + }) |
| 12 | + |
| 13 | + it('should return true if the given term is a xsd:boolean literal', () => { |
| 14 | + const term = rdf.literal('true', ns.xsd.boolean) |
| 15 | + |
| 16 | + strictEqual(isBoolean(term), true) |
| 17 | + }) |
| 18 | + }) |
| 19 | + |
| 20 | + describe('isDecimal', () => { |
| 21 | + it('should be a function', () => { |
| 22 | + strictEqual(typeof isDecimal, 'function') |
| 23 | + }) |
| 24 | + |
| 25 | + it('should return true if the given term is a xsd:decimal literal', () => { |
| 26 | + const term = rdf.literal('12.34', ns.xsd.decimal) |
| 27 | + |
| 28 | + strictEqual(isDecimal(term), true) |
| 29 | + }) |
| 30 | + }) |
| 31 | + |
| 32 | + describe('isDouble', () => { |
| 33 | + it('should be a function', () => { |
| 34 | + strictEqual(typeof isDouble, 'function') |
| 35 | + }) |
| 36 | + |
| 37 | + it('should return true if the given term is a xsd:double literal', () => { |
| 38 | + const term = rdf.literal('1.2E3', ns.xsd.double) |
| 39 | + |
| 40 | + strictEqual(isDouble(term), true) |
| 41 | + }) |
| 42 | + }) |
| 43 | + |
| 44 | + describe('isLangString', () => { |
| 45 | + it('should be a function', () => { |
| 46 | + strictEqual(typeof isLangString, 'function') |
| 47 | + }) |
| 48 | + |
| 49 | + it('should return true if the given term is a rdf:langString literal', () => { |
| 50 | + const term = rdf.literal('Hello World!', 'en') |
| 51 | + |
| 52 | + strictEqual(isLangString(term), true) |
| 53 | + }) |
| 54 | + }) |
| 55 | + |
| 56 | + describe('isInteger', () => { |
| 57 | + it('should be a function', () => { |
| 58 | + strictEqual(typeof isInteger, 'function') |
| 59 | + }) |
| 60 | + |
| 61 | + it('should return true if the given term is a xsd:integer literal', () => { |
| 62 | + const term = rdf.literal('1234', ns.xsd.integer) |
| 63 | + |
| 64 | + strictEqual(isInteger(term), true) |
| 65 | + }) |
| 66 | + }) |
| 67 | + |
| 68 | + describe('isString', () => { |
| 69 | + it('should be a function', () => { |
| 70 | + strictEqual(typeof isString, 'function') |
| 71 | + }) |
| 72 | + |
| 73 | + it('should return true if the given term is a xsd:string literal', () => { |
| 74 | + const term = rdf.literal('Hello World!') |
| 75 | + |
| 76 | + strictEqual(isString(term), true) |
| 77 | + }) |
| 78 | + }) |
| 79 | +}) |
0 commit comments