数通智联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

45 lines
1.1 KiB

var test = require('tape');
var match = require('./');
test('image/jpeg matches image/jpeg', function(t) {
t.plan(1);
t.ok(match('image/jpeg', 'image/jpeg'));
});
test('image/jpeg matches image/*', function(t) {
t.plan(1);
t.ok(match('image/jpeg', 'image/*'));
});
test('image/jpeg does not match application/pdf', function(t) {
t.plan(1);
t.notOk(match('image/jpeg', 'application/pdf'));
});
test('image/jpeg does not match application/*', function(t) {
t.plan(1);
t.notOk(match('image/jpeg', 'application/*'));
});
test('can filter out a match from an array of patterns', function(t) {
t.plan(1);
t.deepEquals(
['application/*', 'image/*'].filter(match('image/jpeg')),
['image/*']
);
});
test('can use wildcards with suffix definitions', function(t) {
t.plan(1);
t.ok(match('application/atom+xml', 'application/*+xml'));
});
test('can use wildcards with vendor part', function(t) {
t.plan(1);
t.ok(match('audio/vnd.rn-realaudio', 'audio/vnd.*'));
});
test('charset suffix is ignored', function(t) {
t.plan(1);
t.ok(match('application/json', 'application/json; charset=utf-8'));
});