blob: c8d34bf81766c32a3993fe8fe3f644d978b8c37c [file] [log] [blame]
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +01001// Copyright 2019 The Chromium Authors
Copybara854996b2021-09-07 19:36:02 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import {assert} from 'chai';
6import {cueNameToSpec, specToCueName} from './cue-helpers.js';
7
8
9describe('cue-helpers', () => {
10 describe('cueNameToSpec', () => {
11 it('appends cue prefix', () => {
12 assert.equal(cueNameToSpec('test'), 'cue.test');
13 });
14 });
15
16 describe('specToCueName', () => {
17 it('extracts cue name from matching spec', () => {
18 assert.equal(specToCueName('cue.test'), 'test');
19 assert.equal(specToCueName('cue.hello-world'), 'hello-world');
20 assert.equal(specToCueName('cue.under_score'), 'under_score');
21 });
22
23 it('does not extract cue name from non-matching spec', () => {
24 assert.equal(specToCueName('.cue.test'), '');
25 assert.equal(specToCueName('hello-world-cue.'), '');
26 assert.equal(specToCueName('cu.under_score'), '');
27 assert.equal(specToCueName('field'), '');
28 });
29 });
30});