channel mapper fn that uses _ underscore JS library
(t *testing.T)
| 238 | |
| 239 | // channel mapper fn that uses _ underscore JS library |
| 240 | func TestChannelMapperUnderscoreLib(t *testing.T) { |
| 241 | underscore.Enable() // It really slows down unit tests (by making otto.New take a lot longer) |
| 242 | defer underscore.Disable() |
| 243 | ctx := base.TestCtx(t) |
| 244 | mapper := NewChannelMapper(ctx, `function(doc) {channel(_.first(doc.channels));}`, 0) |
| 245 | res, err := mapper.MapToChannelsAndAccess(ctx, parse(t, `{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) |
| 246 | assert.NoError(t, err, "MapToChannelsAndAccess failed") |
| 247 | assert.Equal(t, BaseSetOf(t, "foo"), res.Channels) |
| 248 | } |
| 249 | |
| 250 | // Validation by calling reject() |
| 251 | func TestChannelMapperReject(t *testing.T) { |
nothing calls this directly
no test coverage detected