github.com/argoproj/argo-cd@v1.8.7/ui/src/app/applications/components/label-selector.test.ts (about)

     1  import * as LabelSelector from './label-selector';
     2  
     3  test('exists', () => {
     4      expect(LabelSelector.match('test', {test: 'hello'})).toBeTruthy();
     5      expect(LabelSelector.match('test1', {test: 'hello'})).toBeFalsy();
     6      expect(LabelSelector.match('app.kubernetes.io/instance', {'app.kubernetes.io/instance': 'hello'})).toBeTruthy();
     7  });
     8  
     9  test('not exists', () => {
    10      expect(LabelSelector.match('!test', {test: 'hello'})).toBeFalsy();
    11      expect(LabelSelector.match('!test1', {test: 'hello'})).toBeTruthy();
    12  });
    13  
    14  test('in', () => {
    15      expect(LabelSelector.match('test in 1, 2, 3', {test: '1'})).toBeTruthy();
    16      expect(LabelSelector.match('test in 1, 2, 3', {test: '4'})).toBeFalsy();
    17      expect(LabelSelector.match('test in 1, 2, 3', {test1: '1'})).toBeFalsy();
    18  });
    19  
    20  test('notIn', () => {
    21      expect(LabelSelector.match('test notin 1, 2, 3', {test: '1'})).toBeFalsy();
    22      expect(LabelSelector.match('test notin 1, 2, 3', {test: '4'})).toBeTruthy();
    23      expect(LabelSelector.match('test notin 1, 2, 3', {test1: '1'})).toBeTruthy();
    24  });
    25  
    26  test('equal', () => {
    27      expect(LabelSelector.match('test=hello', {test: 'hello'})).toBeTruthy();
    28      expect(LabelSelector.match('test=world', {test: 'hello'})).toBeFalsy();
    29      expect(LabelSelector.match('test==hello', {test: 'hello'})).toBeTruthy();
    30  });
    31  
    32  test('notEqual', () => {
    33      expect(LabelSelector.match('test!=hello', {test: 'hello'})).toBeFalsy();
    34      expect(LabelSelector.match('test!=world', {test: 'hello'})).toBeTruthy();
    35  });
    36  
    37  test('greaterThen', () => {
    38      expect(LabelSelector.match('test gt 1', {test: '2'})).toBeTruthy();
    39      expect(LabelSelector.match('test gt 3', {test: '2'})).toBeFalsy();
    40  });
    41  
    42  test('lessThen', () => {
    43      expect(LabelSelector.match('test lt 1', {test: '2'})).toBeFalsy();
    44      expect(LabelSelector.match('test lt 3', {test: '2'})).toBeTruthy();
    45  });