This repository has been archived on 2026-04-03. You can view files and clone it, but cannot push or open issues or pull requests.
nyx/node_modules/speakingurl/test/test-separator.js
Nico e2667f8e12 Initial nyx project — fork of hermes-frontend
Forked from hermes-frontend, stripped openclaw/bun specifics:
- Auth tokens: openclaw_session -> nyx_session
- Vite proxy: localhost:3003 -> localhost:8000 (assay)
- Prod WS: wss://assay.loop42.de/ws
- Workspace paths: removed openclaw-specific paths
- Added missing deps: @heroicons/vue, overlayscrollbars-vue
- Branding: title -> nyx

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 20:23:27 +02:00

181 lines
4.2 KiB
JavaScript

/* global describe,it */
var getSlug = require('../lib/speakingurl');
describe('getSlug separator', function () {
'use strict';
it('should separate with non-whitespace', function (done) {
getSlug('Foo Bar Baz', {
separator: '-'
})
.should.eql('foo-bar-baz');
getSlug('Foo Bar Baz', {
separator: '*'
})
.should.eql('foo*bar*baz');
getSlug('Foo Bar Baz', {
separator: '_'
})
.should.eql('foo_bar_baz');
getSlug('Foo Bar Baz', '-')
.should.eql('foo-bar-baz');
getSlug('Foo Bar Baz', '*')
.should.eql('foo*bar*baz');
getSlug('Foo Bar Baz', '_')
.should.eql('foo_bar_baz');
done();
});
it('should separate with non-whitespace, with trailing spaces', function (done) {
getSlug(' Foo Bar Baz ', {
separator: '-'
})
.should.eql('foo-bar-baz');
getSlug(' Foo Bar Baz ', {
separator: '*'
})
.should.eql('foo*bar*baz');
getSlug(' Foo Bar Baz ', {
separator: '_'
})
.should.eql('foo_bar_baz');
getSlug(' Foo Bar Baz ', '-')
.should.eql('foo-bar-baz');
getSlug(' Foo Bar Baz ', '*')
.should.eql('foo*bar*baz');
getSlug(' Foo Bar Baz ', '_')
.should.eql('foo_bar_baz');
done();
});
it('should separate with trailing separator "-"', function (done) {
getSlug('-Foo Bar Baz-', {
separator: '-'
})
.should.eql('foo-bar-baz');
getSlug('--Foo Bar Baz---', {
separator: '-'
})
.should.eql('foo-bar-baz');
getSlug('---Foo Bar Baz---', {
separator: '-'
})
.should.eql('foo-bar-baz');
getSlug('-Foo Bar Baz-', '-')
.should.eql('foo-bar-baz');
getSlug('--Foo Bar Baz---', '-')
.should.eql('foo-bar-baz');
getSlug('---Foo Bar Baz---', '-')
.should.eql('foo-bar-baz');
done();
});
it('should separate with trailing separator "*"', function (done) {
getSlug('*Foo Bar Baz*', {
separator: '*'
})
.should.eql('foo*bar*baz');
getSlug('**Foo Bar Baz**', {
separator: '*'
})
.should.eql('foo*bar*baz');
getSlug('***Foo Bar Baz***', {
separator: '*'
})
.should.eql('foo*bar*baz');
getSlug('*Foo Bar Baz*', '*')
.should.eql('foo*bar*baz');
getSlug('**Foo Bar Baz**', '*')
.should.eql('foo*bar*baz');
getSlug('***Foo Bar Baz***', '*')
.should.eql('foo*bar*baz');
done();
});
it('should separate with trailing separator "_"', function (done) {
getSlug('_Foo Bar Baz_', {
separator: '_'
})
.should.eql('foo_bar_baz');
getSlug('__Foo Bar Baz__', {
separator: '_'
})
.should.eql('foo_bar_baz');
getSlug('___Foo Bar Baz___', {
separator: '_'
})
.should.eql('foo_bar_baz');
getSlug('_Foo Bar Baz_', '_')
.should.eql('foo_bar_baz');
getSlug('__Foo Bar Baz__', '_')
.should.eql('foo_bar_baz');
getSlug('___Foo Bar Baz___', '_')
.should.eql('foo_bar_baz');
done();
});
it('should remove trailing separator "*"', function (done) {
getSlug(' C\'est un beau titre qui ne laisse rien à désirer !', {
separator: '*'
})
.should.eql(
'c*est*un*beau*titre*qui*ne*laisse*rien*a*desirer');
getSlug(' C\'est un beau titre qui ne laisse rien à désirer !',
'*')
.should.eql(
'c*est*un*beau*titre*qui*ne*laisse*rien*a*desirer');
done();
});
it('should return empty string because of non string input', function (done) {
getSlug(true)
.should.eql('');
done();
});
});