{"size": 1117, "ext": "js", "max_stars_repo_path": "packages/dd-trace/test/tagger.spec.js", "max_stars_repo_name": "hong823/dd-trace-js", "max_stars_repo_stars_event_min_datetime": "2018-04-08T17:49:09.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T19:59:31.000Z", "max_issues_repo_path": "packages/dd-trace/test/tagger.spec.js", "max_issues_repo_name": "hong823/dd-trace-js", "max_issues_repo_issues_event_min_datetime": "2018-04-11T18:51:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:17:00.000Z", "max_forks_repo_path": "packages/dd-trace/test/tagger.spec.js", "max_forks_repo_name": "hong823/dd-trace-js", "max_forks_repo_forks_event_min_datetime": "2018-05-01T01:24:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-27T23:59:42.000Z"}
{"max_stars_count": 313, "max_issues_count": 1012, "max_forks_count": 198, "avg_line_length": 23.7659574468, "max_line_length": 55, "alphanum_fraction": 0.5846016115}
'use strict'

describe('tagger', () => {
  let carrier
  let tagger

  beforeEach(() => {
    tagger = require('../src/tagger')
    carrier = {}
  })

  it('should add tags as an object', () => {
    tagger.add(carrier, { foo: 'bar' })

    expect(carrier).to.have.property('foo', 'bar')
  })

  it('should add tags as a string', () => {
    tagger.add(carrier, 'foo:bar,baz:qux:quxx,invalid')

    expect(carrier).to.have.property('foo', 'bar')
    expect(carrier).to.have.property('baz', 'qux:quxx')
    expect(carrier).to.not.have.property('invalid')
  })

  it('should add tags as an array', () => {
    tagger.add(carrier, ['foo:bar', 'baz:qux'])

    expect(carrier).to.have.property('foo', 'bar')
    expect(carrier).to.have.property('baz', 'qux')
  })

  it('should store the original values', () => {
    tagger.add(carrier, { foo: 123 })

    expect(carrier).to.have.property('foo', 123)
  })

  it('should handle missing key/value pairs', () => {
    expect(() => tagger.add(carrier)).not.to.throw()
  })

  it('should handle missing carrier', () => {
    expect(() => tagger.add()).not.to.throw()
  })
})
